//
//  MemberTestCase.swift
//  MKCodableTests
//
//  Created by 苏尚进 on 2020/5/9.
//  Copyright © 2020 moon. All rights reserved.
//

import Foundation
import XCTest
import MKCodable

class MemberTestCase : XCTestCase {
    func testMember() {
        let jsonString = """
{
    "name":"sushangjin",
    "nickName":"moon",
    "gender":"2",
    "age":18,
    "phone":"10086",
    "birthday":"2020-05-19 10:20:00",
    "location":{"latitude":23.001,"longitude":123.321232},
    "income":12345.6789,
    "money":329.01
}
"""
        let json = try! JSONSerialization.jsonObject(with: jsonString.data(using: .utf8)!, options: [])
        let m = Member.mkcodable.decodeFromJSON(json)
        let json2 = m?.mkcodable.encodeToJSON()
        let s = m?.mkcodable.encodeToJSONString()
        let s2 = m?.mkcodable.encodeToJSONString([])
        let jsonString2 = String.init(data: try! JSONSerialization.data(withJSONObject: json2!, options: []), encoding: .utf8)
        print("s:\(s!),s2:\(s2!),jsonString2:\(jsonString2!)")
    }
}
